It's not uncommon for writers to be inspired by ideas they come across in other books. When Gabriel Garcia Marquez read Franz Kafka's The Metamorphsis, which begins with a character waking up to find he has transformed into a cockroach, his ideas about writing were revolutionized. “I thought to myself that I didn't know anyone was allowed to write things like that," Garcia Marquez said. “If I had known, I would have started writing a long time ago." Those familiar with Garcia Marquez's work know his fiction is littered with moments of magic, such as angels fallen from the sky. Garcia Marquez certainly hasn't infringed on Kafka's work in doing this. Instead, he's used it as a jumping off point to develop his own way of inhabiting a world that tests the boundaries of fiction.
Themes and ideas have a high level of generality and while they are certainly important in a work of fiction, it is the specificity of character and situation that really bring those abstract notions to life. Emily Bronte's Wuthering Heights and F. Scott Fitzgerald's The Great Gatsby both share common threads: doomed love, the return of the underdog, and the woman in the middle. Yet, they are completely different novels. The Great Gatsby is set in the 1920s, and Gatsby is brooding and patient in winning Daisy back, moving close to her home and throwing elaborate parties with the hope that she will show up. Wuthering Heights opens in the early 1800s, and Heathcliff is more assertive, returning home with the goal of exacting revenge on those who kept him from his love, Catherine.
Indeed, there are a slew of books that follow the hero going on a journey to save something (or someone) of value, from Joseph Conrad's Heart of Darkness to J.R.R. Tolkien's The Lord of the Rings. It's not uncommon for writers to hit on similar ideas, even if they haven't been exposed to those ideas in the past. This is why ideas themselves can't be copyrighted.
So, if you find a theme or idea in another book that inspires you, by all means embrace that. It's no different than being inspired by a snippet of dialogue you overhear at the museum, or your overly friendly boss, or the couple in the booth next to you at the diner who fought through their whole breakfast. The key, of course, comes in developing individual characters and actions that make the story uniquely yours. At some point, you're going to find the specifics of your original inspiration fade into the darkness, while the vibrancy of your creation takes the spotlight.